package com.example.dbsample.config.database;

import lombok.Data;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@ConditionalOnProperty(
        prefix = "spring.datasource.primary",
        name = {"enable"},
        havingValue = "true"
)
@AutoConfigureOrder(1000)   // 这个无实际意义，只是为了说明用法
@Configuration
@ConfigurationProperties(prefix="spring.datasource")
@Data
public class DataSourceConfig {
    public DataSourceConfig() {

    }

    private String url;
    private String username;
    private String password;
    //private String driverClassName = "org.postgresql.Driver";
    //private String driverClassName = "com.mysql.cj.jdbc.Driver";
    //private int initialSize = 8;
    //private int minIdle = 5;
    //private int maxActive = 20;
    //private int maxIdle;
    //private int maxWait = 60000;
    private String driverClassName;
    private int initialSize;
    private int minIdle;
    private String maxActive;
    private int maxIdle;
    private int maxWait;
    private long timeBetweenEvictionRunsMillis;
    private long minEvictableIdleTimeMillis;
    //private String validationQuery = "SELECT 1";
    private String validationQuery;
    private boolean testOnBorrow;
    //private boolean testOnReturn = false;
    private boolean testOnReturn;
    private boolean testWhileIdle;
    private boolean poolPreparedStatements;
    //private int maxPoolPreparedStatementPerConnectionSize = 10;
    private int maxPoolPreparedStatementPerConnectionSize;
    //private String filters = "stat,wall,slf4j";
    private String filters;
}
